<template>
	<view class="my">
		<view class="top">
			<uni-nav-bar dark :fixed="true"  background-color="#007AFF" status-bar left-icon="left" left-text="返回"
						title="个人信息" @clickLeft="back" :border="false" />
			<!-- <uni-card is-full :isShadow="false"> -->
			<view class="info" @click="gotoMyInfo()">
				<view class="info2">
					<img :src="user.avatar" alt=""  style="height: 125rpx; width: 125rpx; border-radius: 50%; margin: 15rpx;background-color: #fff;"/>
					<view class="name">
						<text>{{user.name}}</text>
					</view>
				</view>
				<uni-icons type="right" size="23" style="margin-right: 25rpx; margin-top: 50rpx; color: #333;"></uni-icons>
			</view>
		</view>
		
		<view class="list">
<!-- 			<view v-for="item in list" :key="list.index" class="list-item">
				<view class="msg">
					<uni-icons :type="item.icon" size="23"></uni-icons>
					<text style="margin-left: 10rpx;">{{item.name}}</text>
				</view>
				<view class="bt">
					<uni-icons type="right" size="10"></uni-icons>
				</view>
				<u-line></u-line>
			</view> -->
			<view class="list-item" @click="gotoPage('adress')">
				<view class="msg">
					<uni-icons type="location" size="23"></uni-icons>
					<text style="margin-left: 10rpx;">地址管理</text>
				</view>
				<view class="bt">
					<uni-icons type="right" size="10"></uni-icons>
				</view>
			</view>
			<u-line></u-line>
			<view class="list-item"  @click="gotoPage('orders')">
				<view class="msg">
					<uni-icons type="calendar" size="23"></uni-icons>
					<text style="margin-left: 10rpx;">订单管理</text>
				</view>
				<view class="bt">
					<uni-icons type="right" size="10"></uni-icons>
				</view>
			</view>

		</view>
		
		<view class="btbt">
			<u-button type="error" text="清除缓存" @click="cleanRedis()" ></u-button>
		</view>
	</view>
</template>

<script>
import {cleanRedis} from "@/api/common.js"
	export default {
		data(){
			return{
				user:{
					avatar:'https://web-kotori.oss-cn-beijing.aliyuncs.com/dbf76c48-964a-4ddb-a58b-389eb81a1378.jpg',
					name:'微信用户',

				},
				list:[
					{
						index:0,
						name:'地址管理',
						icon:'location'
					},
					{
						index:1,
						name:'订单管理',
						icon:'calendar'
					},
				]
			}
		},
		onLoad() {
			
		},
		onReady(){
			this.init()
		},
		onShow(){
			this.init()
		},
		methods: {
			init(){
				this.user = this.$store.getters.userInfo
				if(this.user.avatar == null)
					this.user.avatar = 'https://web-kotori.oss-cn-beijing.aliyuncs.com/dbf76c48-964a-4ddb-a58b-389eb81a1378.jpg'
				if(this.user.name == null)
					this.user.name == "微信用户"
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			gotoPage(page){
				uni.navigateTo({
					url:'/pages/'+page+'/'+page
				})
			},
			gotoMyInfo(){
				uni.navigateTo({
					url:'/pages/myInfo/myInfo'
				})
			},
			cleanRedis(){
				cleanRedis().then(res=>{
					uni.showToast({
						title:res.msg,
						icon:"success"
					})
				}).catch(err=>{
					uni.showToast({
						title:err.msg,
						icon:"error"
					})
				})
			}

		},
	}
</script>

<style>
.info{
	background-color: #007AFF;
	height: 170rpx;
	width: 100%;
	display: flex;
	justify-content: space-between;
}
.info2{
	display: flex;

}
.name{
	margin-left: 25rpx;
	margin-top: 50rpx;
	font-weight: 600;
	font-size: 36rpx
}

.list{
	margin-top: 26rpx;
	background-color: #fff;
	width: 96%;
	border-radius: 5rpx;
	margin-left: 14rpx;
	
	
}
.list-item{
	height: 100rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-left: 23rpx;
}
.msg{
	display: flex;
	align-items: center;
}
.my{
	background-color: #F0F0F0;
}

.bt{
	margin-right: 15rpx;
}
.btbt{
	display: flex;
	justify-content: center;
	align-items: center;
	width: 95%;
	position: fixed;
	bottom: 100rpx;
	margin-left: 18rpx;
}
</style>